<?php
session_start();
    if ($_SESSION['login'] == '')
    {
        $currentFile = $_SERVER["PHP_SELF"];
        $parts = Explode('/', $currentFile);
        
        if($parts[count($parts) - 1] != 'login.php' && $parts[count($parts) - 1] != 'contact.php'){
            header('Location: ../login.php');
        }
    }
    if ($_SESSION['login'] != 'haennil') {
         header('Location: ../index.php');
    }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML>
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <!-- PHP Nanomus 2010 by Cyril Levert - Mini CMS without database XHTML 1.0 Strict valide -->

        <meta name="viewport" content="width=device-width, initial-scale=1"> 
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title><?php echo $texts['home'][$_SESSION['lang']] ?></title> 
	<link rel="StyleSheet" type="text/css" href="admin/style.css"/>
        <script type="text/javascript" src="admin/js/prototype.js"></script>
        <script type="text/javascript" src="admin/js/scriptaculous.js"></script>
        <script type="text/javascript" src="admin/multiupload.js"></script>
    </head> 
    <body onload="init();">
		<div id="header">
                    <h1>Web Event Manager</h1>
                    <h2>Administration Galeries</h2>
		</div>
		<div id="mid">
			<div id="main">
				<div id="upload">
		            <h4>Ajout d'une galerie photos</h4>
		            
		            <div id="fichiers">
		                Aucune photos à uploader
		            </div>
		            <br/>
		            <form id="form" action="addPhotosUpload.php" method="post" enctype="multipart/form-data">
		                Uploader cette photo : 
		                <!-- CE SPAN RECOIT LES DIFFERENTS INPUTS CREES PUIS CACHES UNE FOIS UTILISES -->
		                <span id="input"></span> 
		                <br/>
		                Galerie existante :
		                <?php
			                $dir_nom = 'picture/photos/images/'; // dossier listé (pour lister le répertoir courant : $dir_nom = '.'  --> ('point')
							$dir = opendir($dir_nom) or die('Erreur de listage : le répertoire n\'existe pas'); // on ouvre le contenu du dossier courant
							$fichier= array();
							$dossier= array();
							
							while($element = readdir($dir)) {
								if($element != '.' && $element != '..') {
									if (!is_dir($dir_nom.'/'.$element)) {$fichier[] = $element;}
									else {$dossier[] = $element;}
								}
							}
							
							closedir($dir);
							if(!empty($dossier)) {
								sort($dossier);
								echo "<select name=\"GalerieE\">";
									foreach($dossier as $lien){
                                                                            if (strlen($lien)<3)
										echo '<option value="'.$lien.'">'.$lien.'</option>';
									}
								echo "</select>";
							}
						?>
		                <br/>ou nouvelle galerie : <input type='text' name='galerie' maxlength="20" class='txt'/>
		                <br/>
		                <input class="btn" type="submit" value="Uploader"/>
		            </form>
		        </div>
			</div>
			

		</div>
        <div id="break"></div>
		<div id="footer">
			<a href="./index.php" rel="external"><img src="picture/home.png" /></a>
		</div>
	</body>